//
//  User.swift
//  SinaWeibo
//
//  Created by 胡阳 on 16/5/31.
//  Copyright © 2016年 young4ever. All rights reserved.
//

import UIKit

class User: NSObject {

    /// 用户ID
    var id : Int = 0
    /// 友好显示名称
    var name : String?
    /// 头像图片链接<50X50px>
    var avatar_hd : String?{
        didSet{
            if let url = avatar_hd {
                let imgURL = NSURL(string: url)
                imageURL = imgURL
            }
        }
    }
    /// 是否认证
    var verified : Bool = false
    /// 用户认证类型
    var verified_type : Int = -1 {
    
        didSet{
        
            switch verified_type
            {
                case 0:
                    verifyImage = UIImage(named: "avatar_vip")
                case 2, 3, 5:
                    verifyImage = UIImage(named: "avatar_enterprise_vip")
                case 220:
                    verifyImage = UIImage(named: "avatar_grassroot")
                default:
                    verifyImage = nil
            }
        }
    }
    var mbrank : Int = 0 {
        didSet{
        
            if mbrank > 0 && mbrank < 7 {
                vipImage = UIImage(named: "common_icon_membership_level" + "\(mbrank)")
            }
        }
    }
    
    
    /// 用户头像URL
    var imageURL : NSURL?
    /// 认证图片
    var verifyImage : UIImage?
    /// vip图片
    var vipImage : UIImage?
    
    
    init(dict: [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    var properties = ["name", "id", "avatar_hd", "verified", "verified_type"]
    
    override var description: String {
        
        let dict = dictionaryWithValuesForKeys(properties)
        return "\(dict)"
    }
}
